'''
    Goblinoid: Experience all of MediaGoblin on an Android Device
    Copyright (C) 2015 Dylan Jeffers

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
'''

from __future__ import print_function

from kivy.app import App
from kivy.properties import ObjectProperty, StringProperty
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen, SlideTransition
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.actionbar import ActionBar

Builder.load_file('screens/actionview.kv')


class OptionsBar(AnchorLayout):
    pressed = StringProperty()

    def on_pressed(self, instance, value):
        pass


class GoblinBar(ActionBar):
    pass


class ActionLayout(Screen):
    asm = ObjectProperty(ScreenManager())
    options_bar = ObjectProperty()

    def __init__(self, **kwargs):
        super(ActionLayout, self).__init__(**kwargs)
        self.transition = SlideTransition(duration=.35)
        self.asm.transition = self.transition
        # note: currently using pump model, but will eventually have its
        # own model
        self.asm.pump_service = App.get_running_app().pump_service
        self.open_action_view('feed', False)

    def open_action_view(self, name, previous):
        print('got to open_view: {0}, {1}'.format(name, previous))
        if self.asm.has_screen(name):
            self.asm.remove_widget(self.asm.get_screen(name))
        # grabs screen from dictionary of screens
        screen = self.asm.pump_service.screen_dict[name](name=name)
        self.asm.add_widget(screen)
        if previous:
            self.transition.direction = 'right'
        else:
            self.transition.direction = 'left'
        self.asm.current = screen.name


class SettingsScreen(Screen):
    pass
